package com.wnnight.wys.mapper.role;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wnnight.wys.entity.role.Role;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @ClassName: RoleMapper
 * @Description: //TODO
 * @author: dz
 * @date: 2022-08-31-14:24
 */
public interface RoleMapper extends BaseMapper<Role> {

    //根据角色id 查角色信息带出菜单
    @Select("select * from wys_role where id=#{id}")
    @Results({
            @Result(column = "id", property = "id", id = true),
            @Result(column = "id", property = "menuPerms", many = @Many(select = "com.wnnight.wys.mapper.role.MenuPermMapper.getByRoleId"))
    })
    Role getById(int id);

    @Select("select * from wys_role")
    List<Role> getRoles();
}
